import { LoginDto, ProposalDto } from './dtos'

export function Authorization(userData: LoginDto) {
    return Promise.resolve(
        new Promise(function (resolve, reject) {
            resolve({ access_token: 'token ' + userData.login }), reject({ statusCode: '500' })
        })
    )
}

export function GetUserInfo() {
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve({ login: 'mock', id: 'mock_id' })
        })
    )
}

export function GetProposals() {
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve([
                {
                    id: 'mock 2',
                    status: { code: 'DRAFT' },
                    city: { code: 'MOCK_3' },
                    auto: {
                        autoCategory: { code: 'MOCK_3' },
                        model: { code: 'MOCK_4' },
                    },
                },
                {
                    id: 'mock 3',
                    status: { code: 'PENDING' },
                    city: { code: 'MOCK_4' },
                    auto: {
                        autoCategory: { code: 'MOCK_3' },
                        model: { code: 'MOCK_3' },
                    },
                },
                {
                    id: 'mock 4',
                    status: { code: 'REJECTED' },
                    city: { code: 'MOCK_1' },
                    auto: {
                        autoCategory: { code: 'MOCK_4' },
                        model: { code: 'MOCK_2' },
                    },
                },
                {
                    id: 'mock 1',
                    status: { code: 'SUCCESS' },
                    city: { code: 'MOCK_2' },
                    auto: {
                        autoCategory: { code: 'MOCK_4' },
                        model: { code: 'MOCK_1' },
                    },
                },
            ])
        })
    )
}

export function GetProposalById(id: string) {
    console.log('get proposal', id)
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve({
                person: {
                    firstName: 'mockFirstName',
                    lastName: 'mockLastName',
                    driverLicense: 'mockDriverLicense',
                    email: 'mock@mail.ru',
                },
            })
        })
    )
}

export function GetDictionary(code: string) {
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve([
                {
                    name: 'mock ' + code + ' 1',
                    code: 'MOCK ' + code + ' 1',
                },
                {
                    name: 'mock ' + code + ' 2',
                    code: 'MOCK ' + code + ' 2',
                },
                {
                    name: 'mock ' + code + ' 3',
                    code: 'MOCK ' + code + ' 3',
                },
            ])
        })
    )
}

export function AddProposal(requestBody: ProposalDto) {
    console.log(JSON.stringify(requestBody))
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve(requestBody)
        })
    )
}

export function DeleteProposal(id: string) {
    console.log('delete', id)
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve(id)
        })
    )
}

export function RewriteProposal(requestBody: ProposalDto) {
    console.log(JSON.stringify(requestBody))
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve(requestBody)
        })
    )
}

export function SendProposal(id: string) {
    console.log('send', id)
    return Promise.resolve(
        new Promise(function (resolve) {
            resolve(id)
        })
    )
}
